﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJ.Data.Inventory;
using Microsoft.Practices.Unity;
using PJ.Framework.Common;


namespace PJ.Business.Inventory
{
    /// <summary>
    /// InventoryItem class
    /// </summary>
    public class InventoryItem : Item<IInventoryItemData>, IInventoryItem
    {
        private IInventoryItemSalesParam m_InventoryItemSalesParam;
        private IInventoryItemSalesParamService m_InventoryItemSalesParamService;

        private IInventoryItemSalesParamService InventoryItemSalesParamService
        {
            get 
            {
                if (m_InventoryItemSalesParamService == null)
                    m_InventoryItemSalesParamService = InjectionBroker.Resolve<IInventoryItemSalesParamService>();
                return m_InventoryItemSalesParamService;
            }
        }

        public InventoryItem(IInventoryItemData data)
            : base(data)
        {
        }
        public InventoryItem()
        {
        }

        public override string Id
        {
            set
            {
                m_InventoryItemSalesParam = null;
                base.Id = value;
            }
        }

        public IInventoryItemSalesParam InventoryItemSalesParam
        {
            get 
            { 
                if (m_InventoryItemSalesParam == null)
                    m_InventoryItemSalesParam = InventoryItemSalesParamService.GetById(this.Id, PJ.Data.GetDataMode.CachedFind) as IInventoryItemSalesParam;
                return m_InventoryItemSalesParam;
            }
        }
    }
}
